From aa5bd38137fb11e068eb8a4759cc91fbef9c5830 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 4 Feb 2021 00:34:05 -0500 Subject: [PATCH] a11y: Avoid out-of-bounds access Don't use the index before we've checked its good. Pointed out in https://www.viva64.com/en/b/0793/ --- gtk/a11y/gtkatspiaction.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/gtk/a11y/gtkatspiaction.c b/gtk/a11y/gtkatspiaction.c index fb39abf8d5..d31cda147b 100644 --- a/gtk/a11y/gtkatspiaction.c +++ b/gtk/a11y/gtkatspiaction.c @@ -68,10 +68,8 @@ action_handle_method (GtkAtSpiContext *self, g_variant_get (parameters, "(i)", &idx); - const Action *action = &actions[idx]; - if (idx >= 0 && idx < n_actions) - g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", action->name)); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", actions[idx].name)); else g_dbus_method_invocation_return_error (invocation, G_IO_ERROR, @@ -129,10 +127,8 @@ action_handle_method (GtkAtSpiContext *self, g_variant_get (parameters, "(i)", &idx); - const Action *action = &actions[idx]; - if (idx >= 0 && idx < n_actions) - g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", action->keybinding)); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", actions[idx].keybinding)); else g_dbus_method_invocation_return_error (invocation, G_IO_ERROR, -- 2.30.2